Encoding:

P32A

001000

rt

rs

rd

SUBU.PH

0

1100001

101

P32A

001000

rt

rs

rd

SUBU_S.PH

1

1100001

101

6

5

5

5

1

7

3

Format:

SUBU[_S].PH 

Subtract Unsigned Integer Halfwords

SUBU.PH    rd, rs, rt

DSP-R2

Subtract Unsigned Integer Halfwords

SUBU_S.PH  rd, rs, rt

DSP-R2

Subtract Unsigned Integer Halfwords

Purpose:

Subtract Unsigned Integer Halfwords

Element-wise subtraction of pairs of unsigned integer halfwords, with optional saturation.

Description:

rd = sat16(rs31..16 - rt31..16) || sat16(rs15..0 - rt15..0)

The two unsigned integer halfwords in register rs are subtracted from the corresponding unsigned integer halfwords in register rt. The unsigned results are then written to the corresponding element in destination register rd.

In the saturating version of the instruction, if either subtraction results in an underflow the result is clamped to the minimum unsigned integer halfword value (0x0000 hexadecimal), before being written to the destination register rd.

For both instruction variants, if either subtraction causes an underflow the instruction writes a 1 t o bit 20 in the

DSPControl register in the ouflag field.

Restrictions:

No data-dependent exceptions are possible.

The operands must be a value in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

SUBU.PH 
   ValidateAccessToDSP2Resources()
   tempB15..0 = subtractU16U16( GPR[rt]31..16 , GPR[rs]31..16 )
   tempA15..0 = subtractU16U16( GPR[rt]15..0 , GPR[rs]15..0 )
   GPR[rd]31..0 = tempB15..0 || tempA15..0
SUBU_S.PH 
   ValidateAccessToDSPResources()
   tempB15..0 = satU16SubtractU16U16( GPR[rt]31..16 , GPR[rs]31..16 )
   tempA15..0 = satU16SubtractU16U16( GPR[rt]15..0 , GPR[rs]15..0 )
   GPR[rd]31..0 = tempB15..0 || tempA15..0
function subtractU16U16( a15..0, b15..0 ) 
   temp16..0 = ( 0 || a15..0 ) - ( 0 || b15..0 )
   if ( temp16 = 1 ) then
      DSPControlouflag:20 = 1 
   endif
   return temp15..0
endfunction subtractU16U16 
function satU16SubtractU16U16( a15..0, b15..0 ) 
   temp16..0 = ( 0 || a15..0 ) - ( 0 || b15..0 )
   if ( temp16 = 1 ) then
      temp15..0 = 0x0000
      DSPControlouflag:20 = 1 
   endif
   return temp15..0
endfunction satU16SubtractU16U16

Exceptions:

Reserved Instruction, DSP Disabled